package com.polytech.dao;

import java.util.Collection;
import java.util.HashMap;

import com.polytech.beans.Brand;

public class MemoryBrandDao implements BrandDao {

	private HashMap<String, Brand> brands=new HashMap<>();
	public MemoryBrandDao() {
		insert(new Brand("Citroen", 1));
		insert(new Brand("AlphaRomeo", 1));
		insert(new Brand("BMW", 3));
		insert(new Brand("Audi", 3));
		insert(new Brand("Bugatti", 4));
	}
	@Override
	public void insert(Brand brand) {
		brands.put(brand.getLabel(), brand);
	}
	@Override
	public Brand select(String key) {
		return brands.get(key);
	}
	@Override
	public void remove(Brand brand) {
			brands.remove(brand.getLabel());
	}
	@Override
	public Collection<Brand> selectAll() {
		return brands.values();
	}

}
